package com.zw.mes.module.shipments.service;


import com.zw.mes.entity.shipments.InstShipmentsPlanSheet;
import com.zw.mes.module.shipments.mapper.InstShipmentsPlanEditMapper;
import com.zw.mes.module.shipments.repository.PlanSheetRepository;
import com.zw.mes.module.shipments.repository.ProductDetailRepository;
import com.zw.mes.module.shipments.repository.PurchasedDetailRepository;
import com.zw.mes.module.system.service.LogService;
import com.zw.mes.util.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @Description:
 * @Author: China.wsg
 * @Date: 2020/11/10 15:11
 */
@Service
@SuppressWarnings("all")
public class InstShipmentsPlanEditService {


    @Autowired
    private LogService logService;
    @Autowired
    private InstShipmentsPlanEditMapper instShipmentsPlanEditMapper;
    @Autowired
    private PlanSheetRepository planSheetRepository;
    @Autowired
    private ProductDetailRepository productDetailRepository;
    @Autowired
    private PurchasedDetailRepository purchasedDetailRepository;


    /**
     * 查询所有未提交的发货计划主单
     *
     * @return
     */
    public List<InstShipmentsPlanSheet> selectShipmentsList(InstShipmentsPlanSheet instShipmentsPlanSheet) {
        return instShipmentsPlanEditMapper.selectShipmentsList(instShipmentsPlanSheet);
    }

    /**
     * 修改发货计划主单
     * @param instShipmentsPlanSheet
     */
    public Integer editInstShipmentsPlanSheet(InstShipmentsPlanSheet instShipmentsPlanSheet) {
        instShipmentsPlanSheet.setIsDel(0);
        instShipmentsPlanSheet.setUpdateTime(new Date());
        instShipmentsPlanSheet.setUpdateName(ShiroUtils.getUser().getName());
        planSheetRepository.save(instShipmentsPlanSheet);
        logService.saveLog("修改发货计划单主单", "主键id：" + instShipmentsPlanSheet.getId() + "<br>项目编号：" + instShipmentsPlanSheet.getProCode() + "<br>项目名称：" + instShipmentsPlanSheet.getProName());
        return  1;
    }
}
